import request from '@/utils/request'

/**
 *
 * @param {*} params
 * @returns 获取角色列表
 */
const getRoleList = (params) => {
  return request({ url: '/sys/role', params })
}

/**
 *
 * @param {*} data
 * @returns 新增角色
 */
const addRole = (data) => {
  return request({
    method: 'post',
    url: '/sys/role',
    data
  })
}

/**
 *
 * @param {*} data
 * @returns 更新角色
 */
const updateRole = (data) => {
  return request({ url: `/sys/role/${data.id}`, method: 'put', data })
}

/**
 *
 * @param {*} id
 * @returns 删除角色
 */
const deleteRole = (id) => {
  return request({ url: `/sys/role/${id}`, method: 'delete' })
}

/**
 * 获取角色详情
 */
const getRoleDetail = (id) => {
  return request({ url: `/sys/role/${id}` })
}

/**
 * 分配权限
 */
const assignPerm = (data) => {
  return request({ url: '/sys/role/assignPrem', method: 'put', data })
}

export {
  getRoleList,
  addRole,
  updateRole,
  deleteRole,
  getRoleDetail,
  assignPerm
}
